package com.example.logindb.repository;

import com.example.logindb.entity.Feedback;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface FeedbackRepository extends JpaRepository<Feedback, Integer> {


    @Query("SELECT f FROM Feedback f WHERE f.status = :status AND f.aid != 0 ORDER BY f.time DESC LIMIT 3")
    List<Feedback> findRecentFeedbacks(int status);

    @Query("SELECT f FROM Feedback f WHERE f.status = :status AND f.aid = 0 ORDER BY f.time DESC LIMIT 3")
    List<Feedback> findRecentFeedbacks2(int status);

    Feedback findAllByFid(int id);
}
